package com.woniu.after.app.components;

import com.woniu.exception.LXLGException;
import com.woniu.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(LXLGException.class)
    public Result handlerLXLGException(LXLGException s) {
        s.printStackTrace();
        return Result.getInstance().setCode(s.getCode()).setMsg(s.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result exception(Exception e) {
        e.printStackTrace();
        return Result.getInstance().setCode(500).setMsg(e.getMessage());
    }

}
